//
//  GHSAD_SuccessTableViewCell.m
//  penzer
//
//  Created by 还带大道 on 2018/11/23.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "GHSAD_SuccessTableViewCell.h"

@interface GHSAD_SuccessTableViewCell()
@property (weak, nonatomic) IBOutlet UIView *bgV;
@property (weak, nonatomic) IBOutlet UILabel *number;
@property (weak, nonatomic) IBOutlet UILabel *time;
@property (weak, nonatomic) IBOutlet UILabel *resultDesc;
@property (weak, nonatomic) IBOutlet UILabel *handleTypeDesc;
@property (weak, nonatomic) IBOutlet UILabel *gruelDesc;
@property (weak, nonatomic) IBOutlet UILabel *reasonDesc;
@property (nonatomic,assign) CGFloat height1;
@property (nonatomic,assign) CGFloat height2;
@property (nonatomic,assign) CGFloat height3;

@end

@implementation GHSAD_SuccessTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    //设置阴影
    _bgV.backgroundColor = [UIColor whiteColor];
    _bgV.layer.shadowColor = RZ_COLOR_ALPHA(0, 0, 0, 0.1).CGColor;
    _bgV.layer.cornerRadius = 5;
    _bgV.layer.shadowOffset = CGSizeMake(0,4);
    _bgV.layer.shadowOpacity = 1;
    _bgV.layer.shadowRadius = 15;
}


- (void)setupData
{
    [self setupResultDesc];
    [self setupHandleTypeDesc];
    [self setupGruelDesc];
    [self setupReasonDesc];
    [self layoutIfNeeded];
}


- (void)setupResultDesc
{
    NSString *str1 = @"确认为 ”产品问题“，";
    NSString *str2 = @"已接受买家申诉，申诉成功";
    NSMutableAttributedString *attributeStr = [NSMutableAttributedString new] ;
    NSAttributedString *as1 = [[NSAttributedString alloc] initWithString:str1 attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:RZ_COLOR(51, 51, 51)}];
    [attributeStr appendAttributedString:as1];
    
    NSAttributedString *as2 = [[NSAttributedString alloc] initWithString:str2 attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:RZ_COLOR(255, 46, 46)}];
    [attributeStr appendAttributedString:as2];
    
    //段落样式
    NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
    paragraph.lineSpacing = 5; //设置行间距
    paragraph.alignment = NSTextAlignmentLeft;
    NSDictionary *attributeDict = @{NSKernAttributeName:@0,//字符间距
                                    NSParagraphStyleAttributeName:paragraph};
    
    [attributeStr addAttributes:attributeDict range:NSMakeRange(0, attributeStr.length)];
    _resultDesc.attributedText = attributeStr;
}



- (void)setupHandleTypeDesc
{
    NSString *str = @"平台已垫付买家（**芝）所购买商品实付价格¥3540 元";
    
    //段落样式
    NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
    paragraph.lineSpacing = 5; //设置行间距
    paragraph.alignment = NSTextAlignmentLeft;
    NSDictionary *attributeDict = @{NSKernAttributeName:@0,//字符间距
                                 NSParagraphStyleAttributeName:paragraph,
                                 NSFontAttributeName:[UIFont systemFontOfSize:12],
                                 NSForegroundColorAttributeName:RZ_COLOR(51, 51, 51)};
    
    
    NSMutableAttributedString *attributeStr = [NSMutableAttributedString new];
    NSAttributedString *as1 = [[NSAttributedString alloc] initWithString:str attributes:attributeDict];
    [attributeStr appendAttributedString:as1];
    _handleTypeDesc.attributedText = attributeStr;
    
    //计算高度
    CGSize size = CGSizeMake(RZ_SCREEN_WIDTH-140, MAXFLOAT);
    _height1 = [attributeStr boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin context:nil].size.height + 25;
}




- (void)setupGruelDesc
{
    NSString *str = @"1.系统自动扣除押金 ¥ 5000 元（剩余押金金额：¥ 45000 元整）\n2.扣除供应商 35 积分";
    
    //段落样式
    NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
    paragraph.lineSpacing = 5; //设置行间距
    paragraph.alignment = NSTextAlignmentLeft;
    NSDictionary *attributeDict = @{NSKernAttributeName:@0,//字符间距
                                    NSParagraphStyleAttributeName:paragraph,
                                    NSFontAttributeName:[UIFont systemFontOfSize:12],
                                    NSForegroundColorAttributeName:RZ_COLOR(51, 51, 51)};
    
    
    NSMutableAttributedString *attributeStr = [NSMutableAttributedString new];
    NSAttributedString *as1 = [[NSAttributedString alloc] initWithString:str attributes:attributeDict];
    [attributeStr appendAttributedString:as1];
    _gruelDesc.attributedText = attributeStr;
   
    //计算高度
    CGSize size = CGSizeMake(RZ_SCREEN_WIDTH-140, MAXFLOAT);
    _height2 = [attributeStr boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin context:nil].size.height + 25;
    
}


- (void)setupReasonDesc
{
    NSString *str = @"1.从记录可以看出来，供应商存在隐瞒商品事实问题；\n2. 该用户上传的图片证据基本契合事实；\n3.客服态度强硬，偏离了板扎的服务宗旨。\nps：已经让买家（**芝）退回商品，请注意查收，感谢您的支持。";
    
    //段落样式
    NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
    paragraph.lineSpacing = 5; //设置行间距
    paragraph.alignment = NSTextAlignmentLeft;
    NSDictionary *attributeDict = @{NSKernAttributeName:@0,//字符间距
                                    NSParagraphStyleAttributeName:paragraph,
                                    NSFontAttributeName:[UIFont systemFontOfSize:12],
                                    NSForegroundColorAttributeName:RZ_COLOR(51, 51, 51)};
    
    
    NSMutableAttributedString *attributeStr = [NSMutableAttributedString new];
    NSAttributedString *as1 = [[NSAttributedString alloc] initWithString:str attributes:attributeDict];
    [attributeStr appendAttributedString:as1];
    _reasonDesc.attributedText = attributeStr;
    
    //计算高度
    CGSize size = CGSizeMake(RZ_SCREEN_WIDTH-140, MAXFLOAT);
    _height3 = [attributeStr boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin context:nil].size.height + 25;
    
}



- (void)layoutSubviews
{
    [super layoutSubviews];
}


- (CGFloat)cellH
{
    [self layoutIfNeeded];
    _cellH = CGRectGetMinY(self.handleTypeDesc.frame) + _height1 + _height2 + _height3;
    self.bgV.layer.shadowPath = [UIBezierPath bezierPathWithRect:CGRectMake(0, 0, self.bgV.width, _cellH-12)].CGPath;
    return _cellH;
}


@end
